<?php

declare(strict_types=1);

namespace app\validate\order;

use think\Validate;

class OrderValidate extends Validate
{
    protected $rule = [
        'id' => 'integer|gt:0',
        'order_no' => 'max:40',
        'buyer_user_id' => 'integer|gt:0',
        'buyer_org_id' => 'integer|gt:0',
        'seller_user_id' => 'integer|gt:0',
        'seller_org_id' => 'integer|gt:0',
        'region_id' => 'integer|gt:0',
        'assist_user_id' => 'integer|gt:0',
        'source_channel' => 'max:20',
        'status' => 'in:0,1,2,3,4,5',
        'pay_status' => 'in:0,1,2,3',
        'ship_status' => 'in:0,1,2',
        'finish_status' => 'in:0,1,2',
        'refund_status' => 'in:0,1,2',
        'audit_status' => 'in:0,1,2',
        'shipping_fee' => 'float',
        'discount_amount' => 'float',
        'buyer_remark' => 'max:255',
        'seller_remark' => 'max:255',
        'internal_remark' => 'max:255',
        'audit_remark' => 'max:255',
        'items' => 'require|array',
    ];

    protected $message = [
        'buyer_user_id.integer' => '买家用户ID格式不正确',
        'buyer_user_id.gt' => '买家用户ID格式不正确',
        'buyer_org_id.integer' => '买家组织ID格式不正确',
        'buyer_org_id.gt' => '买家组织ID格式不正确',
        'seller_org_id.integer' => '卖家组织ID格式不正确',
        'seller_org_id.gt' => '卖家组织ID格式不正确',
        'items.require' => '订单明细不能为空',
        'items.array' => '订单明细格式不正确',
    ];

    protected $scene = [
        'create' => [
            'buyer_user_id',
            'buyer_org_id',
            'seller_org_id',
            'seller_user_id',
            'region_id',
            'assist_user_id',
            'source_channel',
            'shipping_fee',
            'discount_amount',
            'buyer_remark',
            'seller_remark',
            'internal_remark',
            'items',
        ],
        'update' => [
            'id',
            'order_no',
            'buyer_user_id',
            'buyer_org_id',
            'seller_user_id',
            'seller_org_id',
            'region_id',
            'assist_user_id',
            'source_channel',
            'status',
            'pay_status',
            'ship_status',
            'finish_status',
            'refund_status',
            'audit_status',
            'shipping_fee',
            'discount_amount',
            'buyer_remark',
            'seller_remark',
            'internal_remark',
            'audit_remark',
        ],
    ];
}
